#ifndef _BUTTON_DRV_H__
#define _BUTTON_DRV_H__
#include "config.h"

#define BTN_ROW_CNT      2
#define BTN_COL_CNT      3

typedef enum
{
    BTN1 = 1,
    BTN2 = 2,
    BTN3 = 3,
    BTN4 = 4,
    BTN5 = 5,
    BTN6 = 6,
}BtnLabel_t;

typedef enum
{
    BTN_STATE_RELEASE = 0,
    BTN_STATE_PRESS,
    BTN_STATE_CONFIRM,
    BTN_STATE_LONG,
}BtnState_t;

typedef struct 
{
    BtnLabel_t btnLabel;
    BtnState_t State;
    uint32_t   lastTime;
    uint32_t   beepTime;
    char       pressOnce;
    uint32_t   longTime;
    void (*BtnCallback)(void);
    void (*BtnLongCallback)(void);
}BtnInfo_t;

typedef struct 
{
    uint8_t port;
    uint8_t pin;
}BtnPin_t;

typedef enum
{
    BTN_CB_FUNC = 0,
    BTN_CB_LONG,
}BtnCbType_t;

void Button_Init(void);
void Button_Scan(void);
void Set_Pin(uint8_t port, uint8_t pin, bit level);
BOOL Read_Pin(uint8_t port, uint8_t pin);
BOOL BtnRegister(BtnLabel_t btnLabel, void (*BtnCallback)(void), BtnCbType_t cbType);

#endif /* _BUTTON_DRV_H__ */
